package main

type Students struct {
	ID     uint    `gorm:"size:10"`
	Name   string  `gorm:"size:16;not null;comment:姓名"`
	Age    int     `gorm:"size:3;not null;comment:年龄"`
	Email  *string `gorm:"size:128;comment:邮箱;unique"` //使用指针是为了存空值
	Gender bool
}

func main() {
	//子查询  使用上次查询的结果作为本次查询的参数
	/*
		查询大于平均年龄的用户
		DB = DB.Session(&gorm.Session{
			Logger: mysqlLogger,
		})
		var students []Students
		等价于原生sql SELECT * FROM `students` WHERE age > (SELECT avg(age) FROM `students`)
		DB.Where("age > (?)", DB.Model(Students{}).Select("avg(age)")).Find(&students)
		fmt.Println(students)
	*/
}
